﻿//统一文件为utf-8编码编译
#pragma execution_character_set("utf-8")
///////////////////////////////////////////////////////////////////////////
// 文件名:     databasestruct.h
// 描述:
// 作者:      颜磊
// 创建时间:   2024-06-08 23:39
///////////////////////////////////////////////////////////////////////////
#ifndef DATABASESTRUCT_H
#define DATABASESTRUCT_H

#include <string>
using namespace std;

#pragma pack(push,1)
struct ProgressInfo{
    int id;
    char path[256];//程序路径
    char name[256];//程序名称
    bool vanish_up;//进程消失拉起
    bool cpu_use_up;//是否通过CPU占用拉起
    int cpu_level;//CPU占用门限
    bool heartbeat_up;//心跳守护
    char heartbeat_msg[256];//心跳守护地址
    bool heartbeat_exit;//心跳主动退出
    bool init_start;//开机启动
    int  start_sleep;//启动延时
    bool daemon_open;//开启守护

    ProgressInfo(){
        memset(this,0,sizeof (ProgressInfo));
        vanish_up = false;
        heartbeat_exit = false;
    }
    void setPath(string str){
        memset(path,0,256);
        memcpy(path,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
    void setName(string str){
        memset(name,0,256);
        memcpy(name,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
    void setHeartbeatMsg(string str){
        memset(heartbeat_msg,0,256);
        memcpy(heartbeat_msg,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
};

#define PROGRESS_START_ERROR        0      //唤醒失败
#define PROGRESS_START_INIT         1       //首启守护唤醒
#define PROGRESS_START_VANISH       2       //常在守护唤醒
#define PROGRESS_START_CPUUSE       3       //CPU守护唤醒
#define PROGRESS_START_HEARTBEAT    4       //心跳守护唤醒
#define PROGRESS_START_USER         5       //用户手动唤醒


struct StartLogInfo{
    int id;
    char start_time[20];//启动时间
    char start_type;//启动类型
    char progress_name[256];//进程名字
    char progress_path[256];//进程路径
    char remark[256];//备注信息

    StartLogInfo(){
        memset(this,0,sizeof (StartLogInfo));

    }

    StartLogInfo(int m_id,string startTime,int startType,string progressName,string progressPath,string m_remark){
        memset(this,0,sizeof (StartLogInfo));
        id = m_id;
        setStartTime(startTime);
        start_type = startType;
        setProgressName(progressName);
        setProgressPath(progressPath);
        setRemark(m_remark);
    }
    StartLogInfo(string startTime,int startType,string progressName,string progressPath,string m_remark){
        memset(this,0,sizeof (StartLogInfo));
        setStartTime(startTime);
        start_type = startType;
        setProgressName(progressName);
        setProgressPath(progressPath);
        setRemark(m_remark);
    }

    void setStartTime(string str){
        memset(start_time,0,20);
        memcpy(start_time,str.c_str(),str.length() < 20 ? str.length() : 20);
    }
    void setProgressName(string str){
        memset(progress_name,0,256);
        memcpy(progress_name,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
    void setProgressPath(string str){
        memset(progress_path,0,256);
        memcpy(progress_path,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
    void setRemark(string str){
        memset(remark,0,256);
        memcpy(remark,str.c_str(),str.length() < 256 ? str.length() : 256);
    }
};
#pragma pack(pop)
#endif // DATABASESTRUCT_H
